#ifndef DOCPARSER_H
#define DOCPARSER_H

#ifndef PCRE_STATIC
#define PCRE_STATIC
#endif

#define OVECCOUNT 60    /* should be a multiple of 3 */

#include "pcre.h"
#include <string>
#include <map>
#include <vector>

using namespace std;

namespace mosqoo
{
    namespace util
    {
        class DocParser
        {
            public:
                /** Default constructor */
                DocParser();
                /** Default destructor */
                virtual ~DocParser();

                /**
                 * @brief Register a regex in the DocParser
                 *
                 * DocParser will generate an id and a nickname for registered regex
                 *
                 * @param regex The regex be registered
                 * @return nickname of registered regex
                 *
                 */
                string registerRegex(string regex);

                /**
                 * @brief Register a regex in the DocParser
                 *
                 * DocParser will generate an id and use the proposed name for registered regex
                 *
                 * @param regex The regex be registered
                 * @param nickname The proposed name for reference when selecting the registered regex
                 * @return nickname of registered regex
                 *
                 */
                string registerRegex(string regex, string key);

                /**
                 * @brief calling a registered regex to search result from the proposed content
                 *
                 * DocParser will parse the proposed content based on the selected registered regex.
                 *
                 * @param nickname The nickname of selected regex in the regex registration
                 * @param content The proposed content for search.
                 * @return string The result string
                 *
                 */
                vector<string> search(string key, string content);

            protected:
            private:
                map<string, pcre*> regexPool;
                const char *error;
                int errorOffset;
        };
    }
}

#endif // DOCPARSER_H
